#pragma once

#include <stdio.h>
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "driver/ledc.h"


#define Level_Positive

#ifdef Level_Positive
    #define On_Level  1
    #define Off_level 0
#else
    #define On_level    1
    #define Off_level   0
#endif


#define BLINK_GPIO      27




class GPIO_LED{
    public:
        GPIO_LED(uint8_t);
        void InitLED();
        void LED_On();
        void LED_Off();
        void Level_flip();

        #if SOC_LEDC_SUPPORT_HS_MODE
            void PWM_EN(ledc_mode_t LEDC_SPEED_MODE = LEDC_HIGH_SPEED_MODE,
                    ledc_channel_t LEDC_CHANNEL = LEDC_CHANNEL_0,
                    ledc_timer_t LEDC_TIMER = LEDC_TIMER_0,
                    int FADE_TIME = 500);

        #else
            void LEDC_FadeEN(ledc_mode_t LEDC_SPEED_MODE = LEDC_LOW_SPEED_MODE,
                        ledc_channel_t LEDC_CHANNEL = LEDC_CHANNEL_0,
                        ledc_timer_t LEDC_TIMER = LEDC_TIMER_0,
                        int FADE_TIME = 800);
        #endif
        
        void LEDC_FadeUp(uint32_t LEDC_DUTY = 8000);
        void LEDC_FadeDown();
        void LEDC_Fade();
        void LEDC_FadeStop();

    private:
        uint8_t IO_Num;
        ledc_channel_config_t ledc_channel;
        ledc_mode_t _SPEED_MODE;
        ledc_channel_t _CHANNEL;
        int _FADE_TIME;

};


